package com.manaka.servlet;

import com.manaka.service.MaintainService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 增加指令Servlet
 *
 * @author Manaka
 * @date 2018-09-08 20:13
 */
public class AddCommandServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //设置编码
        req.setCharacterEncoding("UTF-8");
        //接受页面的值
        String command = req.getParameter("newcommand");
        String description = req.getParameter("newdescription");
        String context = req.getParameter("newcontent");
        //向页面传值

        MaintainService service = new MaintainService();
        service.addCommand(command,description,context);

        //页面跳转
        req.getRequestDispatcher("/List.action").forward(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req,resp);
    }
}
